package com.aplicacion.urgencias;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;

public class PanelPrincipal extends Activity {

	public static final String ROW_ID = "row_id";

	@Override
	public void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState); 
		setContentView(R.layout.panel_principal);

		ImageButton infoButton = (ImageButton) findViewById(R.id.instrucButton);
		infoButton.setOnClickListener(new OnClickListener() {

			public void onClick(View v) 
			{
				final CharSequence[] items={"Agregar paciente","Ver Lista","Buscador"};
				final AlertDialog.Builder alert = new AlertDialog.Builder(new ContextThemeWrapper(PanelPrincipal.this, R.style.AboutDialog));
				final AlertDialog.Builder alert2 = new AlertDialog.Builder(new ContextThemeWrapper(PanelPrincipal.this, R.style.AboutDialog));
				alert.setTitle(R.string.instrucc_ImageButton); 
				alert.setItems(items, new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {	    				  
						if(items[which].equals("Agregar paciente")){
							alert2.setTitle(R.string.instrTitleAgregarPaciente);
							alert2.setMessage(R.string.instrAgregarPaciente);
						} else if(items[which].equals("Ver Lista")){
							alert2.setTitle(R.string.instrTitleVerLista);
							alert2.setMessage(R.string.instrVerLista);
						} else if(items[which].equals("Buscador")){
							alert2.setTitle(R.string.instrTitleBuscador);
							alert2.setMessage(R.string.instrBuscador);
						}
						alert2.setPositiveButton(R.string.instrSalir, null);
						alert2.show();
					}
				});
				alert.setPositiveButton(R.string.instrSalir, null);
				alert.show();
			}
		});	  

	}

	public void agregarPacienteButtonClick(View view)  
	{  
		Intent agregarContact = new Intent(PanelPrincipal.this, AgregarEditarPaciente.class);
		startActivity(agregarContact);
	} 

	public void verListaButtonClick(View view)  
	{  
		Intent listaContact = new Intent(PanelPrincipal.this, Lista.class);
		startActivity(listaContact);  
	} 

	public void buscadorButtonClick(View view)  
	{  
		Intent buscarContact = new Intent(PanelPrincipal.this, BuscadorVisita.class);
		startActivity(buscarContact);
	} 
	
	public void mapaButtonClick(View view)  
	{  
//		Intent mapaIntent = new Intent(android.content.Intent.ACTION_VIEW,
//		Uri.parse("geo:0,0?q=http://sites.google.com/site/urgarchivoskml/home/KML_URG.kml"));
//		startActivity(mapaIntent);
		
		Intent mapaIntent = new Intent(PanelPrincipal.this, VerMapa.class);
		startActivity(mapaIntent);
		
//		String url1 = "geo:0,0?q=Aguado 224";
//		Intent intent = new Intent(android.content.Intent.ACTION_VIEW,  Uri.parse(url1));
//		startActivity(intent);
	} 

}
